package com.ruoyi.web.controller.combat.equiplocation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.equiplocation.CombatFakeIp;
import com.ruoyi.combat.service.equiplocation.ICombatFakeIpService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 虚假IPController
 * 
 * @author ruoyi
 * @date 2025-07-22
 */
@RestController
@RequestMapping("/combat/fakeip")
public class CombatFakeIpController extends BaseController
{
    @Autowired
    private ICombatFakeIpService combatFakeIpService;

    /**
     * 查询虚假IP列表
     */
    @PreAuthorize("@ss.hasPermi('combat:fakeip:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatFakeIp combatFakeIp)
    {
        startPage();
        List<CombatFakeIp> list = combatFakeIpService.selectCombatFakeIpList(combatFakeIp);
        return getDataTable(list);
    }

    /**
     * 导出虚假IP列表
     */
    @PreAuthorize("@ss.hasPermi('combat:fakeip:export')")
    @Log(title = "虚假IP", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatFakeIp combatFakeIp)
    {
        List<CombatFakeIp> list = combatFakeIpService.selectCombatFakeIpList(combatFakeIp);
        ExcelUtil<CombatFakeIp> util = new ExcelUtil<CombatFakeIp>(CombatFakeIp.class);
        util.exportExcel(response, list, "虚假IP数据");
    }

    /**
     * 获取虚假IP详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:fakeip:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatFakeIpService.selectCombatFakeIpById(id));
    }

    /**
     * 新增虚假IP
     */
    @PreAuthorize("@ss.hasPermi('combat:fakeip:add')")
    @Log(title = "虚假IP", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatFakeIp combatFakeIp)
    {
        return toAjax(combatFakeIpService.insertCombatFakeIp(combatFakeIp));
    }

    /**
     * 修改虚假IP
     */
    @PreAuthorize("@ss.hasPermi('combat:fakeip:edit')")
    @Log(title = "虚假IP", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatFakeIp combatFakeIp)
    {
        return toAjax(combatFakeIpService.updateCombatFakeIp(combatFakeIp));
    }

    /**
     * 删除虚假IP
     */
    @PreAuthorize("@ss.hasPermi('combat:fakeip:remove')")
    @Log(title = "虚假IP", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatFakeIpService.deleteCombatFakeIpByIds(ids));
    }
}
